Skip to content

Conversation

@tswast
Copy link
Collaborator

@tswast tswast commented Oct 22, 2025

This commit implements the isnan and isfinite numpy ufuncs in bigframes.

The following changes were made:

  • Added IsNanOp and IsFiniteOp to bigframes/operations/numeric_ops.py
  • Mapped np.isnan and np.isfinite to the new ops in bigframes/operations/numpy_op_maps.py
  • Added compilation logic for the new ops to the ibis, polars, and sqlglot compilers
  • Added tests for the new ops in tests/system/small/test_numpy.py

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes b/454341854🦕

This commit implements the `isnan` and `isfinite` numpy ufuncs in bigframes.

The following changes were made:
- Added `IsNanOp` and `IsFiniteOp` to `bigframes/operations/numeric_ops.py`
- Mapped `np.isnan` and `np.isfinite` to the new ops in `bigframes/operations/numpy_op_maps.py`
- Added compilation logic for the new ops to the ibis, polars, and sqlglot compilers
- Added tests for the new ops in `tests/system/small/test_numpy.py`
@tswast tswast requested review from a team as code owners October 22, 2025 18:18
@tswast tswast requested a review from TrevorBergeron October 22, 2025 18:18
@product-auto-label product-auto-label bot added the size: m Pull request size is medium. label Oct 22, 2025
@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. label Oct 22, 2025
google-labs-jules bot and others added 2 commits October 22, 2025 18:31
This commit implements the `isnan` and `isfinite` numpy ufuncs in bigframes.

The following changes were made:
- Added `IsNanOrNullOp` and `IsFiniteOp` to `bigframes/operations/numeric_ops.py`
- Mapped `np.isnan` and `np.isfinite` to the new ops in `bigframes/operations/numpy_op_maps.py`
- Added compilation logic for the new ops to the ibis, polars, and sqlglot compilers
- Added tests for the new ops in `tests/system/small/test_numpy.py`
- Renamed `IsNanOp` to `IsNanOrNullOp` to match numpy semantics and updated compilers accordingly.
unsafe_pow_op = UnsafePowOp()

IsNanOp = base_ops.create_unary_op(
name="isnanornull",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 7f1bca4, thanks.

@polars_compiler.register_op(numeric_ops.IsNanOp)
def is_nan_op_impl(
compiler: polars_compiler.PolarsExpressionCompiler,
op: numeric_ops.SqrtOp, # type: ignore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type annotation

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 7f1bca4, thanks.

@polars_compiler.register_op(numeric_ops.IsFiniteOp)
def is_finite_op_impl(
compiler: polars_compiler.PolarsExpressionCompiler,
op: numeric_ops.SqrtOp, # type: ignore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

annotation

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 7f1bca4, thanks.

@tswast tswast merged commit 68723bc into main Oct 24, 2025
25 checks passed
@tswast tswast deleted the add-isnan-isfinite branch October 24, 2025 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. size: m Pull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants